﻿<%@ Page Title="" Language="C#" MasterPageFile="~/master_form.master" AutoEventWireup="true" CodeFile="Nhap_hs.aspx.cs" Inherits="App_Form_gv_giang_vien" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <style type="text/css">
        .x-form-clear {
            background-image: url('../../resources/themes/images/default/form/search-trigger.gif');
            background-position: 0 0;
            width: 17px;
            height: 22px;
            border-bottom: 1px solid #b5b8c8;
            cursor: pointer;
            cursor: hand;
            overflow: hidden;
        }
    </style>
    <script type="text/javascript" src="../js/plugin/CellEditing.js"></script>
    <script type="text/javascript">
        var tgiao = "";
        Ext.Loader.setConfig({
            enabled: true
        });
        Ext.Loader.setPath('Ext.ux', '../ux');

        Ext.require([
        'Ext.selection.CellModel',
        'Ext.grid.*',
        'Ext.data.*',
        'Ext.util.*',
        'Ext.state.*',
        'Ext.form.*',
        'Ext.grid.Panel',
        'Ext.layout.container.Column'
        ]);
        function P_DATA(b_ma) {
            Ext.onReady(function () {

                Ext.QuickTips.init();
                var bd = Ext.getBody();

                var gridForm = Ext.create('Ext.form.Panel', {
                    id: 'sinhvien',
                    frame: true,
                    bodyPadding: 5,
                    layout: {
                        type: 'table',
                        columns: 2
                    },
                    fieldDefaults: {
                        labelAlign: 'left',
                        msgTarget: 'side'
                    },

                    items: [
                        {
                            margin: '0 0 5 5',
                            xtype: 'fieldset',
                            title: 'Thông tin ảnh',
                            defaults: {
                                width: 200,
                                heigth: 200,
                                labelWidth: 90
                            },
                            defaultType: 'textfield',
                            items: [
                            {
                                xtype: 'fieldcontainer',
                                combineErrors: true,
                                layout: {
                                    type: 'hbox',
                                    defaultMargins: { top: 0, right: 5, bottom: 0, left: 0 }
                                },
                                items: [
                                     {
                                         xtype: 'image',
                                         src: '',
                                         height: 200,
                                         id: 'anh',
                                         width: 200,
                                         border: true,
                                         listeners: {
                                             el: {
                                                 click: function () {
                                                     var win = new Ext.Window({
                                                         title: 'Upload', width: 420, height: 82, plain: true,
                                                         buttons: [
                                                         {
                                                             text: 'OK',
                                                             handler: function () {
                                                                 win.close();
                                                             }
                                                         }
                                                         ],
                                                         html: String.format('<iframe id="upload" frameborder="0" src="../Upload/upload.aspx" width="100%" height="100%" />'),
                                                         listeners: {
                                                             close: function () {
                                                                 var q = $("#upload").contents().find("#someID").html();
                                                                 if (q == "") return;
                                                                 Ext.getCmp("anh").setSrc("../../images/" + q);

                                                             }
                                                         }
                                                     });

                                                     win.show(this); // animate to location
                                                     win.center(); // center window 
                                                 }
                                             },
                                             beforeRender: function (e) {
                                                 e.style = "cursor:pointer;";
                                             }
                                         }
                                     }
                                ]
                            }
                            ]
                        },
                        {
                            margin: '0 0 5 5',
                            xtype: 'fieldset',
                            title: 'Thông tin chung',
                            defaults: {
                                width: 700,
                                labelWidth: 90
                            },
                            defaultType: 'textfield',
                            items: [
                            {
                                xtype: 'fieldcontainer',
                                combineErrors: true,
                                defaultType: 'textfield',
                                layout: {
                                    type: 'hbox',
                                    defaultMargins: { top: 0, right: 5, bottom: 0, left: 0 }
                                },
                                items: [
                                      { xtype: 'displayfield', width: 80, fieldLabel: 'Họ tên đệm' },
                                      {
                                          id: 'tendem', name: 'hodem', width: 150
                                      },
                                      { xtype: 'displayfield', width: 80, fieldLabel: 'Tên' },
                                      { id: 'Ten', name: 'ten', width: 135 },
                                      { xtype: 'displayfield', width: 80, fieldLabel: 'T.Thường gọi' },
                                      { id: 'bidanh', name: 'bidanh', width: 135 }

                                ]
                            },
                            {
                                xtype: 'fieldcontainer', combineErrors: true, defaultType: 'textfield',
                                layout: {
                                    type: 'hbox',
                                    defaultMargins: { top: 0, right: 5, bottom: 0, left: 0 }
                                },
                                items: [
                                     { xtype: 'displayfield', width: 80, fieldLabel: 'Ngày sinh' },
                                     {
                                         xtype: 'datefield', value: '', format: 'd/m/Y', name: 'ngaysinh',
                                         id: 'ngaysinh', width: 150, renderer: Ext.util.Format.dateRenderer('d/m/Y')
                                     },
                                     { xtype: 'displayfield', width: 80, fieldLabel: 'Giới tính' },
                                     {
                                         id: 'gioitinh', width: 135, xtype: 'combo', emptyText: 'Chọn giới tính', editable: false, value:'Nam',
                                         name: 'gioitinh', displayField: 'id', valueField: 'Ten',
                                         store: [
                                            ['Nam', 'Nam'],
                                            ['Nữ', 'Nữ']
                                         ]
                                     },
                                     { xtype: 'displayfield', width: 80, fieldLabel: 'Số hộ chiếu' },
                                     { id: 'so_hc', name: 'so_hc', width: 135 }
                                ]
                            },
                             {
                                 xtype: 'fieldcontainer', combineErrors: true, defaultType: 'textfield',
                                 layout: {
                                     type: 'hbox',
                                     defaultMargins: { top: 0, right: 5, bottom: 0, left: 0 }
                                 },
                                 items: [
                                      { xtype: 'displayfield', width: 80, fieldLabel: 'CMT' },
                                      { id: 'cmt', name: 'cmt', width: 150 },
                                      { xtype: 'displayfield', width: 80, fieldLabel: 'Ngày cấp' },
                                       {
                                           xtype: 'datefield', value: '', format: 'd/m/Y', name: 'ngay_cap',
                                           id: 'ngay_cap', width: 135, renderer: Ext.util.Format.dateRenderer('d/m/Y')
                                       },
                                       { xtype: 'displayfield', width: 80, fieldLabel: 'Nơi cấp' },
                                       { id: 'noi_cap', name: 'noi_cap', width: 135 }
                                 ]
                             },
                            {
                                xtype: 'fieldcontainer', combineErrors: true, defaultType: 'textfield',
                                layout: {
                                    type: 'hbox',
                                    defaultMargins: { top: 0, right: 5, bottom: 0, left: 0 }
                                },
                                items: [
                                     { xtype: 'displayfield', width: 80, fieldLabel: 'Quê quán' },
                                     {
                                         id: 'que_quan', name: 'que_quan', width: 374
                                     },
                                     { xtype: 'displayfield', width: 80, fieldLabel: 'Dân tộc' },
                                     {
                                         width: 135, xtype: 'combo', triggerAction: 'all', emptyText: 'Chọn dân tộc',
                                         forceSelection: true, editable: false, id: 'dantoc', name: 'dan_toc',
                                         displayField: 'TEN_DANTOC', valueField: 'MA_DANTOC', store: null
                                     }
                                ]
                            },
                            {
                                xtype: 'fieldcontainer', combineErrors: true, defaultType: 'textfield',
                                layout: {
                                    type: 'hbox',
                                    defaultMargins: { top: 0, right: 5, bottom: 0, left: 0 }
                                },
                                items: [
                                     { xtype: 'displayfield', width: 80, fieldLabel: 'Nơi sinh' },
                                     {
                                         id: 'noi_sinh', name: 'noi_sinh', width: 374
                                     },
                                     { xtype: 'displayfield', width: 80, fieldLabel: 'Tôn giáo' },
                                     {
                                         xtype: 'combobox', triggerAction: 'all', id: 'ton_giao', name: 'ton_giao',
                                         store: null, displayField: 'TEN_TONGIAO', valueField: 'MA_TONGIAO', editable: false,
                                         listClass: 'x-combo-list-small', width: 135, emptyText: 'Chọn tôn giáo'
                                     }
                                ]
                            },
                            {
                                xtype: 'fieldcontainer', combineErrors: true, defaultType: 'textfield',
                                layout: {
                                    type: 'hbox',
                                    defaultMargins: { top: 0, right: 5, bottom: 0, left: 0 }
                                },
                                items: [
                                     { xtype: 'displayfield', width: 80, fieldLabel: 'Nơi ở' },
                                     {
                                         id: 'noi_o', name: 'noi_o', width: 374
                                     },
                                     { xtype: 'displayfield', width: 80, fieldLabel: 'Tình trạng', tooltip: 'Tình trạng của bản thân' },
                                     {
                                         id: 'tinh_trang', name: 'tinh_trang', width: 135
                                     }
                                ]
                            },
                            {
                                xtype: 'fieldcontainer', combineErrors: true, defaultType: 'textfield',
                                layout: {
                                    type: 'hbox',
                                    defaultMargins: { top: 0, right: 5, bottom: 0, left: 0 }
                                },
                                items: [
                                     { xtype: 'displayfield', width: 80, fieldLabel: 'Phòng ban' },
                                     {
                                         width: 150, xtype: 'combo', triggerAction: 'all',
                                         emptyText: 'Chọn phòng ban', forceSelection: true,
                                         editable: false, id: 'phong_ban',
                                         name: 'phong_ban', displayField: 'Ten', valueField: 'id_phong',
                                         store: null
                                     },
                                      { xtype: 'displayfield', width: 80, fieldLabel: 'Chức vụ' },
                                     {
                                         width: 135, xtype: 'combo', emptyText: 'Chọn chức vụ',
                                         forceSelection: true, editable: false,
                                         id: 'chuc_vu', name: 'chuc_vu', displayField: 'Ten',
                                         valueField: 'id_cv', store: null
                                     },
                                     { xtype: 'displayfield', width: 80, fieldLabel: 'TĐ học vấn' },
                                     {
                                         width: 135, xtype: 'combo', emptyText: 'Chọn trình độ',
                                         editable: false, id: 'hoc_van', name: 'hoc_van', displayField: 'Ten',
                                         valueField: 'id_td', store: null
                                     }
                                ]
                            },
                            {
                                xtype: 'fieldcontainer', combineErrors: true, defaultType: 'textfield',
                                layout: {
                                    type: 'hbox',
                                    defaultMargins: { top: 0, right: 5, bottom: 0, left: 0 }
                                },
                                items: [
                                     { xtype: 'displayfield', width: 80, fieldLabel: 'Loại HĐ' },
                                     {
                                         width: 150, xtype: 'combo', triggerAction: 'all',
                                         emptyText: 'Chọn hợp đồng',
                                         editable: false, id: 'hop_dong',
                                         name: 'hop_dong', displayField: 'Ten', valueField: 'id_hd',
                                         store: null
                                     },
                                      { xtype: 'displayfield', width: 80, fieldLabel: 'Ngày tuyển' },
                                     {
                                         xtype: 'datefield', value: '', format: 'd/m/Y', name: 'ngay_tuyen',
                                         id: 'ngay_tuyen', width: 135, renderer: Ext.util.Format.dateRenderer('d/m/Y')
                                     },
                                     { xtype: 'displayfield', width: 80, fieldLabel: 'Số điện thoại' },
                                     { id: 'so_dt', name: 'so_dt', width: 135 }
                                ]
                            },
                            {
                                xtype: 'fieldcontainer',
                                combineErrors: true,
                                defaultType: 'textfield',
                                layout: {
                                    type: 'hbox',
                                    defaultMargins: { top: 0, right: 5, bottom: 0, left: 0 }
                                },
                                items: [
                                    { xtype: 'displayfield', width: 80, fieldLabel: 'Chế độ CS' },
                                     {
                                         width: 150, xtype: 'combo', triggerAction: 'all',
                                         emptyText: 'Chọn chế độ chính sách',
                                         editable: false, id: 'chinh_sach',
                                         name: 'chinh_sach', displayField: 'Ten', valueField: 'id_cs',
                                         store: null
                                     },
                                     { xtype: 'displayfield', width: 80, fieldLabel: 'Ngày NN' },
                                     { id: 'ngay_nn', name: 'ngay_nn', xtype: 'datefield', width: 135, format: 'd/m/Y' },
                                     { xtype: 'displayfield', width: 80, fieldLabel: 'Ngày XN' },
                                     { id: 'ngay_xn', xtype: 'datefield', name: 'ngay_xn', width: 135, format: 'd/m/Y' }
                                ]
                            }
                            ]
                        },
                        {
                            margin: '0 0 5 5',
                            xtype: 'fieldset',
                            colspan: 2,
                            title: '',
                            defaults: {
                                width: 630,
                                heigth: 200,
                                labelWidth: 90
                            },
                            defaultType: 'textfield',
                            items: [
                                 {
                                     region: 'center', width: '100%',
                                     heigth: 200, id: 'tab',
                                     xtype: 'tabpanel',
                                     items: [
                                       {
                                           xtype: 'grid', id: 'qhgd', title: 'Quan hệ gia đình',
                                           plugins: Ext.create('Ext.grid.plugin.CellEditing', {
                                               clicksToEdit: 1
                                           }),
                                           store: ds,
                                           columns: [
                                               { header: 'id', hidden: true, dataIndex: 'QH_ID' },
                                               { header: 'ma_sv', hidden: true, dataIndex: 'MA_SV' },
                                               {
                                                   header: 'Loại', dataIndex: 'loai', width: 73, flex: 1,
                                                   editor: {
                                                       xtype: 'combobox', typeAhead: true,
                                                       width: 70, triggerAction: 'all', selectOnTab: true,
                                                       store: [
                                                           ['Bố', 'Bố'],
                                                           ['Mẹ', 'Mẹ'],
                                                           ['Em gái', 'Em gái'],
                                                           ['Em trai', 'Em trai'],
                                                           ['Em gái', 'Em gái'],
                                                           ['Chị gái', 'Chị gái'],
                                                           ['Anh trai', 'Anh trai'],
                                                           ['Cháu', 'Cháu']
                                                       ],
                                                       lazyRender: true,
                                                       listClass: 'x-combo-list-small'
                                                   }
                                               },
                                               {
                                                   header: 'Họ và tên', width: 150, dataIndex: 'hoten',
                                                   editor: {
                                                       allowBlank: true
                                                   }
                                               },
                                               {
                                                   header: 'Năm sinh', width: 80, dataIndex: 'nam_sinh',
                                                   editor: {
                                                       allowBlank: true, xtype: 'numberfield', hideTrigger: true
                                                   }
                                               },
                                                {
                                                    header: 'Nghề nghiệp', width: 150, dataIndex: 'nghe_nghiep',
                                                    editor: {
                                                        allowBlank: true
                                                    }
                                                },
                                               {
                                                   header: 'Dân tộc', dataIndex: 'dan_toc', width: 130,
                                                   editor: {
                                                       allowBlank: true, xtype: 'combobox', typeAhead: true,
                                                       triggerAction: 'all', selectOnTab: true, store: null,
                                                       lazyRender: true, displayField: 'TEN_DANTOC', valueField: 'TEN_DANTOC', listClass: 'x-combo-list-small'
                                                   }
                                               },
                                                {
                                                    header: 'Tôn giáo', width: 90, dataIndex: 'ton_giao',
                                                    editor: {
                                                        allowBlank: true, allowBlank: true, xtype: 'combobox', typeAhead: true,
                                                        triggerAction: 'all', selectOnTab: true,
                                                        store: null, lazyRender: true, displayField: 'TEN_TONGIAO', valueField: 'TEN_TONGIAO',
                                                        listClass: 'x-combo-list-small'
                                                    }
                                                },
                                                 {
                                                     header: 'Thường trú', width: 200, dataIndex: 'hktt',
                                                     editor: {
                                                         allowBlank: true
                                                     }
                                                 }
                                           ],
                                           listeners: {
                                               'beforeedit': function (e, b) {
                                                   if (e.field == "dan_toc") {
                                                       var cb = e.column.getEditor();
                                                       cb.bindStore(abc);
                                                   }
                                                   else if (e.field == "ton_giao") {
                                                       var tg = e.column.getEditor();
                                                       tg.bindStore(tgiao);
                                                   }
                                               }
                                           },
                                           height: 200,
                                           width: 400
                                       },
                                       {
                                           xtype: 'grid', id: 'qt_dt', title: 'Quá trình đào tạo',
                                           plugins: Ext.create('Ext.grid.plugin.CellEditing', {
                                               clicksToEdit: 1
                                           }),
                                           store: dsdt,
                                           columns: [
                                               { header: 'id', hidden: true, dataIndex: 'ma_dt' },
                                               { header: 'ma_sv', hidden: true, dataIndex: 'ma_cb' },
                                               {
                                                   header: 'Loại ĐT', dataIndex: 'loaidt', width: 100,
                                                   editor: {
                                                       xtype: 'combobox', typeAhead: true, displayField: 'Ten', valueField: 'ID',
                                                       width: 70, triggerAction: 'all', selectOnTab: true,
                                                       store: null, lazyRender: true, listClass: 'x-combo-list-small'
                                                   }
                                               },
                                               {
                                                   header: 'Từ ngày', width: 150, dataIndex: 'tu_ngay', type: 'date', format: 'd/m/Y',
                                                   renderer: Ext.util.Format.dateRenderer('d/m/Y'),
                                                   editor: {
                                                       xtype: 'datefield', width: 135, format: 'd/m/Y', allowBlank: true
                                                   }
                                               },
                                               {
                                                   header: 'Đến ngày', width: 150, dataIndex: 'den_ngay', type: 'date', dateFormat: 'd/m/y',
                                                   renderer: Ext.util.Format.dateRenderer('d/m/Y'),
                                                   editor: {
                                                       xtype: 'datefield', width: 135, format: 'd/m/Y', allowBlank: true,
                                                       renderer: Ext.util.Format.dateRenderer('d/m/Y')
                                                   }
                                               },
                                               {
                                                   header: 'Ngành đào tạo', width: 150, dataIndex: 'nganh_dt',
                                                   editor: {
                                                       allowBlank: true
                                                   }
                                               },
                                                {
                                                    header: 'Trường đào tạo', width: 200, dataIndex: 'truong_dt', flex: 1,
                                                    editor: {
                                                        allowBlank: true
                                                    }
                                                },
                                               {
                                                   header: 'Xếp loại', width: 80, dataIndex: 'xep_loai',
                                                   editor: {
                                                       xtype: 'combobox', typeAhead: true,
                                                       width: 80, triggerAction: 'all', selectOnTab: true, editable: true,
                                                       store: [
                                                           ['Xuất sắc', 'Xuất sắc'],
                                                           ['Giỏi', 'Giỏi'],
                                                           ['Khá', 'Khá'],
                                                           ['TB.Khá', 'TB.Khá'],
                                                           ['Trung bình', 'Trung bình'],
                                                           ['Yếu', 'Yếu'],
                                                           ['Kém', 'Kém']
                                                       ],
                                                       lazyRender: true,
                                                       listClass: 'x-combo-list-small'
                                                   }
                                               }
                                           ],
                                           listeners: {
                                               'beforeedit': function (e, b) {
                                                   if (e.field == "loaidt") {
                                                       var cb = e.column.getEditor();
                                                       cb.bindStore(loaidt);
                                                   }
                                               }
                                           },
                                           height: 200,
                                           width: 400
                                       },
                                           QuatrinhCT(),
                                           KhenThuong(),
                                           Kyluat()
                                     ]
                                 }
                            ]
                        },
            {
                margin: '0 0 5 5',
                padding: '4 5 4 200',
                xtype: 'fieldset',
                colspan: 2,
                title: '',
                defaults: {
                    width: 600,
                    heigth: 300,
                    labelWidth: 90
                },
                region: 'center',
                items: [
                     {
                         name: 'add',
                         xtype: 'button',
                         width: 90,
                         icon: '../../shared/icons/fam/add.gif',
                         text: 'Thêm mới',
                         handler: function () {
                             var form = this.up('form').getForm()
                             if (form.isValid()) {
                                 var a_kq = new Array();
                                 a_kq = form.getValues();
                                 if (a_kq.length == 0) { alert("Không lấy được dữ liệu"); return; }
                                 // if (!Fb_PT_JSON(a_kq, "dan_toc")) { alert("Chưa chọn dân tộc"); return; }
                                 //if (!Fb_PT_JSON(a_kq, "gioitinh")) { alert("Chưa chọn khu vực"); return; }
                                 var count = 0;
                                 var a_gtri = Fa_JSON_MANG(a_kq)[1], a_ten = Fa_JSON_MANG(a_kq)[0];
                                 count = a_gtri.length;
                                 if (!Fb_PT_JSON(a_kq, "ton_giao")) {
                                     a_gtri[count] = '';
                                     a_ten[count] = "ton_giao";
                                     count++;
                                 }
                                 if (!Fb_PT_JSON(a_kq, "chuc_vu")) {
                                     a_gtri[count] = '';
                                     a_ten[count] = "chuc_vu";
                                     count++;
                                 }
                                 if (!Fb_PT_JSON(a_kq, "hop_dong")) {
                                     a_gtri[count] = '';
                                     a_ten[count] = "hop_dong";
                                     count++;
                                 }
                                 if (!Fb_PT_JSON(a_kq, "phong_ban")) {
                                     a_gtri[count] = '';
                                     a_ten[count] = "phong_ban";
                                     count++;
                                 }
                                 if (!Fb_PT_JSON(a_kq, "chinh_sach")) {
                                     a_gtri[count] = '';
                                     a_ten[count] = "chinh_sach";
                                     count++;
                                 }
                                 if (!Fb_PT_JSON(a_kq, "hoc_van")) {
                                     a_gtri[count] = '';
                                     a_ten[count] = "hoc_van";
                                     count++;
                                 }

                                 //Goi service  
                                 var b_tinhdiem = Ext.getCmp('qhgd');
                                 var a_gtriGrid = new Array();
                                 var i = 0;
                                 b_tinhdiem.getStore().each(function (record) {
                                     if (NVL(record.get("loai"), "") != "") {
                                         //QH_ID,loai, hoten, nam_sinh, nghe_nghiep, dan_toc, ton_giao, hktt
                                         a_gtriGrid[i] = [record.get("QH_ID"), record.get("loai"), record.get("hoten"), record.get("nam_sinh"), record.get("nghe_nghiep")
                                             , record.get("dan_toc"), record.get("ton_giao"), record.get("hktt")
                                         ];
                                         i++;
                                     }
                                 });
                                 //QT_DT
                                 var b_tinhdiem = Ext.getCmp('qt_dt');
                                 var a_gtriGridDT = new Array();
                                 var i = 0;
                                 b_tinhdiem.getStore().each(function (record) {
                                     if (NVL(record.get("loaidt"), "") != "") {
                                         //QH_ID,loai, hoten, nam_sinh, nghe_nghiep, dan_toc, ton_giao, hktt
                                         a_gtriGridDT[i] = [record.get("ma_dt"), record.get("ma_cb"), record.get("loaidt"),
                                             (record.get("tu_ngay").getDate().toString().length == 1 ? "0" + record.get("tu_ngay").getDate() : record.get("tu_ngay").getDate()) + "/" +
                                             ((record.get("tu_ngay").getMonth() + 1).toString().length == 1 ? "0" + (record.get("tu_ngay").getMonth() + 1) : (record.get("tu_ngay").getMonth() + 1)) + "/" + record.get("tu_ngay").getFullYear(),
                                             (record.get("den_ngay").getDate().toString().length == 1 ? "0" + record.get("den_ngay").getDate() : record.get("den_ngay").getDate()) + "/" +
                                             ((record.get("den_ngay").getMonth() + 1).toString().length == 1 ? "0" + (record.get("den_ngay").getMonth() + 1) : (record.get("den_ngay").getMonth() + 1)) + "/" + record.get("den_ngay").getFullYear()
                                             , record.get("nganh_dt"), record.get("truong_dt"), record.get("xep_loai")
                                         ];
                                         i++;
                                     }
                                 });
                                 //Quá trình công tác
                                 var b_tinhdiem = Ext.getCmp('qtct');
                                 var a_gtriGridCT = new Array();
                                 var i = 0;
                                 b_tinhdiem.getStore().each(function (record) {
                                     if (NVL(record.get("ngaydct"), "") != "") {
                                         //"qt_ct", "ma_cb", "ngaydct", "ngaycct", "vi_tri", "cong_ty", "chuc_vu"
                                         a_gtriGridCT[i] = [record.get("qt_ct"), record.get("ma_cb"),
                                             (record.get("ngaydct").getDate().toString().length == 1 ? "0" + record.get("ngaydct").getDate() : record.get("ngaydct").getDate()) + "/" +
                                             ((record.get("ngaydct").getMonth() + 1).toString().length == 1 ? "0" + (record.get("ngaydct").getMonth() + 1) : (record.get("ngaydct").getMonth() + 1)) + "/" + record.get("ngaydct").getFullYear(),
                                             (record.get("ngaycct").getDate().toString().length == 1 ? "0" + record.get("ngaycct").getDate() : record.get("ngaycct").getDate()) + "/" +
                                             ((record.get("ngaycct").getMonth() + 1).toString().length == 1 ? "0" + (record.get("ngaycct").getMonth() + 1) : (record.get("ngaycct").getMonth() + 1)) + "/" + record.get("ngaycct").getFullYear()
                                             , record.get("vi_tri"), record.get("cong_ty"), record.get("chuc_vu")
                                         ];
                                         i++;
                                     }
                                 });
                                 //Khen thuowngr
                                 var b_tinhdiem = Ext.getCmp('khenthuong');
                                 var a_gtriGridKT = new Array();
                                 var i = 0;
                                 b_tinhdiem.getStore().each(function (record) {
                                     if (NVL(record.get("ngay_kt"), "") != "") {
                                         //"id_kt", "ma_cb", "ngay_kt", "danh_hieu", "so_qd", "hinh_thuc", "dvi_kt"
                                         a_gtriGridKT[i] = [record.get("id_kt"), record.get("ma_cb"),
                                             (record.get("ngay_kt").getDate().toString().length == 1 ? "0" + record.get("ngay_kt").getDate() : record.get("ngay_kt").getDate()) + "/" +
                                             ((record.get("ngay_kt").getMonth() + 1).toString().length == 1 ? "0" + (record.get("ngay_kt").getMonth() + 1) : (record.get("ngay_kt").getMonth() + 1)) + "/" + record.get("ngay_kt").getFullYear(),
                                             , record.get("danh_hieu"), record.get("so_qd"), record.get("hinh_thuc"), record.get("dvi_kt")
                                         ];
                                         i++;
                                     }
                                 });
                                 //Ky luat
                                 var b_tinhdiem = Ext.getCmp('kyluat');
                                 var a_gtriGridKL = new Array();
                                 var i = 0;
                                 b_tinhdiem.getStore().each(function (record) {
                                     if (NVL(record.get("ngay_kl"), "") != "") {
                                         //"id_kl", "ma_cb", "ngay_kl", "ly_do", "so_qd", "hinh_thuc", "dvi_kl"
                                         a_gtriGridKL[i] = [record.get("id_kt"), record.get("ma_cb"),
                                             (record.get("ngay_kl").getDate().toString().length == 1 ? "0" + record.get("ngay_kl").getDate() : record.get("ngay_kl").getDate()) + "/" +
                                             ((record.get("ngay_kl").getMonth() + 1).toString().length == 1 ? "0" + (record.get("ngay_kl").getMonth() + 1) : (record.get("ngay_kl").getMonth() + 1)) + "/" + record.get("ngay_kl").getFullYear(),
                                             , record.get("ly_do"), record.get("so_qd"), record.get("hinh_thuc"), record.get("dvi_kl")
                                         ];
                                         i++;
                                     }
                                 });
                                 var url = Ext.getCmp("anh").src, loai = $get("<%=loai.ClientID%>").value;
                                 var b_id = $get("<%=id_ns.ClientID%>").value;
                                 url = url.substring(url.lastIndexOf('/') + 1);
                                 wns.Fs_NHANSU_NH(b_id, url, a_ten, a_gtri, a_gtriGrid, a_gtriGridDT, a_gtriGridCT, a_gtriGridKT, a_gtriGridKL, nhansu_P_KQ, P_LOI_CSDL, P_LOI_TGIAN);
                             }

                         }
                     },
                                 {
                                     name: 'moi',
                                     xtype: 'button',
                                     width: 90,
                                     icon: '../../shared/icons/fam/refesh.png',
                                     text: 'Mới',
                                     handler: function () {
                                         this.up('form').getForm().reset();
                                         var b_tinhdiem = Ext.getCmp('qhgd');
                                         var myData = new Array(4);
                                         for (var i = 0; i < 7; i++) {
                                             myData[i] = ["", "", "", "", "", "", "", "", ""];
                                         }
                                         var dsa = Ext.create('Ext.data.ArrayStore', {
                                             fields: ["id", "ma_sv", "loai", "hoten", "nam_sinh", "nghe_nghiep", "dan_toc", "hktt", "ton_giao"],
                                             data: myData
                                         });
                                         b_tinhdiem.bindStore(dsa);
                                         this.up('form').getForm().reset();
                                         $get("<%=id_ns.ClientID%>").value = "";
                                     }
                                 },
                                 {
                                     name: 'xoa',
                                     xtype: 'button',
                                     width: 90,
                                     icon: '../../shared/icons/fam/delete.gif',
                                     text: 'Xóa',
                                     handler: function () {
                                         var b_ma = Ext.getCmp("ma_sv").getValues();
                                         wdkhp.Fs_SINHVIEN_XOA(b_ma, sinhvienxoa_P_KQ, P_LOI_CSDL, P_LOI_TGIAN);
                                     }
                                 }
                ]
            }
                    ],
                    renderTo: bd
                });
                wns.Fs_TUYEN_SINH_TTCHUNG(P_LOAD_TTCHUNG, P_LOI_CSDL, P_LOI_TGIAN);

            });
                     if (b_ma != "")
                         wdkhp.Fs_SINHVIEN_TIM_MA(b_ma, sinhvientim_P_KQ, P_LOI_CSDL, P_LOI_TGIAN);
                 }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:HiddenField runat="server" ID="loai" Value="N" />
    <asp:HiddenField runat="server" ID="id_ns" Value="" />
    <script type="text/javascript">
        function P_LOAD_TTCHUNG(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            else {
                //debugger;
                var a_kq = b_kq.split('@');
                var b_chuoi1 = CH_JSON(a_kq[0]),
                    b_chuoi2 = CH_JSON(a_kq[1]),
                    b_chuoi3 = CH_JSON(a_kq[2]),
                    b_chuoi4 = CH_JSON(a_kq[3]),
                    b_chuoi5 = CH_JSON(a_kq[4]),
                    b_chuoi6 = CH_JSON(a_kq[5]),
                    b_chuoi7 = CH_JSON(a_kq[6]),
                    b_chuoi8 = CH_JSON(a_kq[7]);


                var a_data1 = Ext.create('Ext.data.Store', {
                    fields: ['MA_DANTOC', 'TEN_DANTOC'],
                    data: b_chuoi1
                });

                var a_data2 = Ext.create('Ext.data.Store', {
                    fields: ['MA_TONGIAO', 'TEN_TONGIAO'],
                    data: b_chuoi2
                });
                tgiao = a_data2;
                //Phong ban
                var a_data3 = Ext.create('Ext.data.Store', {
                    fields: ['id_phong', 'Ten'],
                    data: b_chuoi3
                });

                Ext.getCmp("phong_ban").bindStore(a_data3);

                //Chức vụ

                var a_data4 = Ext.create('Ext.data.Store', {
                    fields: ['id_cv', 'Ten'],
                    data: b_chuoi4
                });

                Ext.getCmp("chuc_vu").bindStore(a_data4);
                //Hopwk đppng

                var a_data5 = Ext.create('Ext.data.Store', {
                    fields: ['id_hd', 'Ten'],
                    data: b_chuoi5
                });

                Ext.getCmp("hop_dong").bindStore(a_data5);
                //Chính sách

                var a_data6 = Ext.create('Ext.data.Store', {
                    fields: ['id_cs', 'Ten'],
                    data: b_chuoi6
                });
                Ext.getCmp("chinh_sach").bindStore(a_data6);
                //Trình đôk
                var a_data7 = Ext.create('Ext.data.Store', {
                    fields: ['id_td', 'Ten'],
                    data: b_chuoi7
                });
                Ext.getCmp("hoc_van").bindStore(a_data7);


                Ext.getCmp("ton_giao").bindStore(a_data2);

                var c = Ext.getCmp('dantoc');
                c.bindStore(a_data1);
                abc = a_data1;
                //Loai dt
                var a_data8 = Ext.create('Ext.data.Store', {
                    fields: ['ID', 'Ten'],
                    data: b_chuoi8
                });
                loaidt = a_data8;
            }
        }

        function P_MON_NGANH_KQ(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            else {
                var b_chuoi = CH_JSON(b_kq);

                var a_data = Ext.create('Ext.data.Store', {
                    fields: ['id_nganhdt', 'ten'],
                    data: b_chuoi
                });

                var b = Ext.getCmp('nganhdt');
                b.clearValue();
                b.setValue("");
                b.setValue(null);
                b.bindStore(a_data);
            }
        }

        function dktkb_xoa_P_KQ(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            else {
                KB_TIM_P_KQ(b_kq);
            }
        }

        function nhansu_P_KQ(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            else {
                $get("<%=id_ns.ClientID%>").value = b_kq;
                alert("Thêm thành công");
            }
        }
        //Timf kiem
        function sinhvientim_P_KQ(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            //Form
            var frm = Ext.getCmp("sinhvien");
            var a_kq = b_kq.split('@');
            var b_chuoi0 = CH_JSON(a_kq[0]),
                b_chuoi1 = CH_JSON(a_kq[1]);

            a_data1 = Ext.create('Ext.data.Store', {
                fields: ["bo_mon", 'ma_sv', 'lop', "nganhdt", "Hodem", "Ten", "ngaysinh",
                              "Noi_sinh", "thuongtru", "doituong", "gioitinh", "dantoc",
                , "khuvuc", "cmt", "ngay_cap", "noi_cap",
                              "sdt", "ngay_nn", "ngay_xn"],
                data: b_chuoi0
            });
            P_MON_NGANH_KQ(a_kq[2]);
            P_LOPNGANH_KQ(a_kq[3]);
            var url = b_chuoi0[0].Url;
            Ext.getCmp("anh").setSrc("../../images/" + url);
            if (a_data1.data.items[0])
                frm.getForm().loadRecord(a_data1.data.items[0]);

            var ds2 = Ext.create('Ext.data.Store', {
                fields: ["QH_ID", "ma_sv", "loai", "hoten", "nam_sinh", "nghe_nghiep", "dan_toc", "hktt", "ton_giao"],
                data: b_chuoi1
            });

            var b_tinhdiem = Ext.getCmp('qhgd');
            b_tinhdiem.bindStore(ds2);
        }
        function sinhvienxoa_P_KQ(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            alert("Xoa thanh cong");
        }
    </script>
</asp:Content>

